package com.line.myprojectservice.utils;

import lombok.AllArgsConstructor;
import lombok.Data;

/**
 * @author ：Line
 * @date ： 2022/3/30 23:11
 * @description :静态方法 返回接口相应数据
 */
@Data
@AllArgsConstructor
public class ResponseUtil {

    private Integer code;

    private String msg;

    private Object data;


    /**
     * 成功
     */
    public static ResponseUtil success() {
        return new ResponseUtil(200, "操作成功", null);
    }

    /**
     * 成功
     */
    public static ResponseUtil success(String msg) {
        return new ResponseUtil(200, msg, null);
    }

    /**
     * 成功
     */
    public static ResponseUtil success(Object data) {
        return new ResponseUtil(200, "操作成功", data);
    }

    /**
     * 成功
     */
    public static ResponseUtil success(String msg, Object data) {
        return new ResponseUtil(200, msg, data);
    }

    /**
     * 失败
     */
    public static ResponseUtil error() {
        return new ResponseUtil(500, "操作失败", null);
    }

    /**
     * 失败
     */
    public static ResponseUtil error(Integer code) {
        return new ResponseUtil(code, null, null);
    }

    /**
     * 失败
     */
    public static ResponseUtil error(Integer code, String msg) {
        return new ResponseUtil(code, msg, null);
    }

    /**
     * 失败
     */
    public static ResponseUtil error(String msg) {
        return new ResponseUtil(500, msg, null);
    }

    /**
     * 失败
     */
    public static ResponseUtil error(Object data) {
        return new ResponseUtil(500, "操作失败", data);
    }

    /**
     * 失败
     */
    public static ResponseUtil error(Integer code, String msg, Object data) {
        return new ResponseUtil(code, msg, data);
    }

}
